package connectDB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectDB {
	private final String PROTOCOL="jdbc:sqlserver://";
	private final String SERVER="localhost";
	private final int PORT=1433;
	private final String DATABASE="QLBH";
	private final String USER="sa";
	private final String PASSWORD="111";
	
	public Connection getConnectDB()
	{
			Connection cnn=null;
				String url=PROTOCOL+SERVER+":"+PORT+";DatabaseName="+DATABASE+";user="+USER+";password="+PASSWORD;
				//+";integratedSecurity=true";
				//
				try {
					
					Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
					
					cnn=DriverManager.getConnection(url);
					
				} catch (SQLException e) {
				
					e.printStackTrace();
				} catch (ClassNotFoundException e) {
					
					e.printStackTrace();
				}
			return cnn;
	}
	
	public static void main(String[] args) {
		ConnectDB cnn = new ConnectDB();
		System.out.println(cnn.getConnectDB());
	}
}
